package idv.loveloser.dao;

import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * A data access object (DAO) providing persistence and search support for
 * MdlWorkshopAssessmentsOld entities. Transaction control of the save(),
 * update() and delete() operations can directly support Spring
 * container-managed transactions or they can be augmented to handle
 * user-managed Spring transactions. Each of these methods provides additional
 * information for how to configure it for the desired type of transaction
 * control.
 * 
 * @see idv.loveloser.dao.MdlWorkshopAssessmentsOld
 * @author MyEclipse Persistence Tools
 */

public class MdlWorkshopAssessmentsOldDAO extends BaseHibernateDAO {
	private static final Logger log = LoggerFactory
			.getLogger(MdlWorkshopAssessmentsOldDAO.class);
	// property constants
	public static final String WORKSHOPID = "workshopid";
	public static final String SUBMISSIONID = "submissionid";
	public static final String USERID = "userid";
	public static final String TIMECREATED = "timecreated";
	public static final String TIMEGRADED = "timegraded";
	public static final String TIMEAGREED = "timeagreed";
	public static final String GRADE = "grade";
	public static final String GRADINGGRADE = "gradinggrade";
	public static final String TEACHERGRADED = "teachergraded";
	public static final String MAILED = "mailed";
	public static final String RESUBMISSION = "resubmission";
	public static final String DONOTUSE = "donotuse";
	public static final String GENERALCOMMENT = "generalcomment";
	public static final String TEACHERCOMMENT = "teachercomment";
	public static final String NEWPLUGIN = "newplugin";
	public static final String NEWID = "newid";

	public void save(MdlWorkshopAssessmentsOld transientInstance) {
		log.debug("saving MdlWorkshopAssessmentsOld instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(MdlWorkshopAssessmentsOld persistentInstance) {
		log.debug("deleting MdlWorkshopAssessmentsOld instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public MdlWorkshopAssessmentsOld findById(java.lang.Long id) {
		log.debug("getting MdlWorkshopAssessmentsOld instance with id: " + id);
		try {
			MdlWorkshopAssessmentsOld instance = (MdlWorkshopAssessmentsOld) getSession()
					.get("idv.loveloser.dao.MdlWorkshopAssessmentsOld", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(MdlWorkshopAssessmentsOld instance) {
		log.debug("finding MdlWorkshopAssessmentsOld instance by example");
		try {
			List results = getSession()
					.createCriteria(
							"idv.loveloser.dao.MdlWorkshopAssessmentsOld")
					.add(Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding MdlWorkshopAssessmentsOld instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from MdlWorkshopAssessmentsOld as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByWorkshopid(Object workshopid) {
		return findByProperty(WORKSHOPID, workshopid);
	}

	public List findBySubmissionid(Object submissionid) {
		return findByProperty(SUBMISSIONID, submissionid);
	}

	public List findByUserid(Object userid) {
		return findByProperty(USERID, userid);
	}

	public List findByTimecreated(Object timecreated) {
		return findByProperty(TIMECREATED, timecreated);
	}

	public List findByTimegraded(Object timegraded) {
		return findByProperty(TIMEGRADED, timegraded);
	}

	public List findByTimeagreed(Object timeagreed) {
		return findByProperty(TIMEAGREED, timeagreed);
	}

	public List findByGrade(Object grade) {
		return findByProperty(GRADE, grade);
	}

	public List findByGradinggrade(Object gradinggrade) {
		return findByProperty(GRADINGGRADE, gradinggrade);
	}

	public List findByTeachergraded(Object teachergraded) {
		return findByProperty(TEACHERGRADED, teachergraded);
	}

	public List findByMailed(Object mailed) {
		return findByProperty(MAILED, mailed);
	}

	public List findByResubmission(Object resubmission) {
		return findByProperty(RESUBMISSION, resubmission);
	}

	public List findByDonotuse(Object donotuse) {
		return findByProperty(DONOTUSE, donotuse);
	}

	public List findByGeneralcomment(Object generalcomment) {
		return findByProperty(GENERALCOMMENT, generalcomment);
	}

	public List findByTeachercomment(Object teachercomment) {
		return findByProperty(TEACHERCOMMENT, teachercomment);
	}

	public List findByNewplugin(Object newplugin) {
		return findByProperty(NEWPLUGIN, newplugin);
	}

	public List findByNewid(Object newid) {
		return findByProperty(NEWID, newid);
	}

	public List findAll() {
		log.debug("finding all MdlWorkshopAssessmentsOld instances");
		try {
			String queryString = "from MdlWorkshopAssessmentsOld";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public MdlWorkshopAssessmentsOld merge(
			MdlWorkshopAssessmentsOld detachedInstance) {
		log.debug("merging MdlWorkshopAssessmentsOld instance");
		try {
			MdlWorkshopAssessmentsOld result = (MdlWorkshopAssessmentsOld) getSession()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(MdlWorkshopAssessmentsOld instance) {
		log.debug("attaching dirty MdlWorkshopAssessmentsOld instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(MdlWorkshopAssessmentsOld instance) {
		log.debug("attaching clean MdlWorkshopAssessmentsOld instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}